<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>列表渲染</title>
</head>
<body>
    <div id="div">
        <ul>
<!--
v-for : 就是增强for循环
            1. 当前标签数量跟被遍历的集合或对象元素一致
            2. 参数
            1). element in names
            names : 被遍历的数组或对象
            element : 元素 (需要用插值表达式获取)

            2). (element,index) in names
            index : 索引
            -->

            <li v-for="element in names">
                {{element}}
            </li>
            <li v-for="element in student">
                {{element}}
            </li>
            <!--
                类似于普通for循环
            -->
            <li v-for="(element,index) in names">
                {{index}},{{element}}
            </li>

            <li v-for="(e,i) in student">
                {{i}},{{e}}
            </li>
        </ul>
    </div>
</body>
<script src="js/vue.js"></script>
<script>
    new Vue({
        el:"#div",
        data:{
            names:["张三","李四","王五"],
            student:{
                name:"张三",
                age:23
            }
        }
    });
</script>
<script>
    let array = ['zs','ls','ww']
    for (let element of array){
        console.log(element);
    }
    for (let index in array){
        console.log(index+":"+array[index]);
    }
    for (let i = 0; i <array.length ; i++) {
        
    }
    /*
    * js对象是可以被遍历的
    *   1. 属性名是索引
    *   2. 属性值是值
    * */

    let jsObj = {
        name:"zs",
        age: 18
    }
    for (let index in jsObj){
        console.log(index+":"+jsObj[index]);
    }
</script>
</html>